#include <iostream>

using namespace std;

const int N = 110;
int a[100010], n, m;
int main()
{
	int n; cin >> n;
	int x;
	while (cin >> x) a[x]++;
	for (int i = 1; i <= 100010; i++)
	{
		if (a[i] > 1) m = i;
		if (a[i - 1] && a[i + 1] && !a[i]) n = i;
	}
	cout << n << " " << m << endl;
	return 0;
}